package chapter6;

import java.util.Scanner;

/****************************************************************
 * Author：icynlau
 * Description: 计算一个字符串中字母的个数
 * Date:2021/4/4
 * ***************************************************************
 */
public class exc6_20 {
	
	public static void main(String[] args) {
		
		Scanner input=new Scanner(System.in);
		
		System.out.print("Enter the string:  ");
		String s=input.nextLine();
		
		System.out.print(" It  has  "+countLetters(s)+" letters.\n");
		
	}
	
	public static int countLetters(String s) {
		
		int n=0;
		
		for(int i=0;i<s.length();i++) {
			
			if(s.charAt(i)>='a' && s.charAt(i)<='z' || s.charAt(i)>='A' && s.charAt(i)<='Z' ) {
				n++;
			}
			
		}
		
		return n;
		
	}

}
